package com.ai.bitcoin.jpa.service.impl;

import com.ai.bitcoin.jpa.dao.BccPriceInfoCrawlDao;
import com.ai.bitcoin.jpa.entity.BccPriceInfoCrawl;
import com.ai.bitcoin.jpa.service.BccPriceInfoCrawlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @author Jason
 * @date 2018/4/6
 **/
@Component
public class BccPriceInfoServiceCrawlImpl implements BccPriceInfoCrawlService {
    @Autowired
    BccPriceInfoCrawlDao dao;


    @Override
    @Transactional
    public BccPriceInfoCrawl save(BccPriceInfoCrawl bccPriceInfo) {
        return dao.save(bccPriceInfo);
    }

    @Override
    public Page<BccPriceInfoCrawl> findByBatchNo(String batchNo, Pageable pageable) {
        return dao.findByBatchNo(batchNo, pageable);
    }

    @Override
    public List<BccPriceInfoCrawl> findByBccIdAndBatchNo(String bccId, String batchNo) {
        return dao.findByBccIdAndBatchNo(bccId, batchNo);
    }

    @Override
    @Transactional
    public void deleteByBatchNo(String batchNo) {
        dao.deleteByBatchNo(batchNo);
    }

    @Override
    @Transactional
    public void deleteByCreateTimeLessThan(Date date) {
        dao.deleteByCreateTimeLessThan(date);
    }
}
